#include <iostream>
#include "Record.h"
#include "Schema.h"
#include "DBFile.h"
#include <stdlib.h>
#include "BigQ.h"

#include "File.h"
extern struct AndList *final;

extern "C" {
	int yyparse(void);   // defined in y.tab.c
}


int main(){
	Schema schema("catalog","orders");
	Record record;
	DBFile dbfile;
	int i ;
	Page page;
	
	//dbfile.Create("./records.db", heap, NULL);
	//dbfile.Load(schema, "./10M/orders.tbl");
	//dbfile.MoveFirst();
	//dbfile.Open("./nation.db");
	
	//BigQ bigq;

	/*
	DBFile myfile;
	//myfile.Open("./SortedPageLenRecords");
	myfile.Open("./heapDB/orders.bin");
	myfile.MoveFirst();
	Record newrecord;

	cout << "========================================================" << endl;
	while (myfile.GetNext(newrecord))
	{
		newrecord.Print(&schema);
	}
	myfile.Close();
*/
	/*dbfile.Close();*/

	/*FILE * file = fopen ( "./10M/lineitem.tbl", "r");
	fclose(file);
	dbfile.Close();
	dbfile.Open("./lineitem.db");
	dbfile.Close();
	File lineitem;
	lineitem.Open(1, "./lineitem.db");
	cout << "total pages in the table : "  << lineitem.GetLength()-1 << endl;
	lineitem.GetPage(&page,0);
	while ( page.GetFirst(&record) )
	{
		record.Print(&schema);
		
	}
	
	while( dbfile.GetNext( record ) )
	{
		record.Print(&schema);
	}
		
	int countPage=0;
	for( i = 0 ; i < 101; i++ ){
			cout << "fetching page: " << countPage++ << endl;
			lineitem.GetPage(&page, i);
	}
	fclose(file);	
	*/
	return 0;
}
